//
//  KKPieChartViewController.swift
//  KKChartViewDemo
//
//  Created by liaozhenming on 2019/11/29.
//  Copyright © 2019 kangcun2019. All rights reserved.
//

import UIKit

class KKPieChartViewController: UIViewController {

    var pieChartView: KKPieChartView?
    
    var cyclicChartView: KKCyclicChartView?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        self.navigationItem.title = "饼图"
        
        let item1 = KKChartDataItem.itemWith(identifier: "", color: UIColor.green, value: 2.0)
        let item2 = KKChartDataItem.itemWith(identifier: "", color: UIColor.yellow, value: 3.0)
        let item3 = KKChartDataItem.itemWith(identifier: "", color: UIColor.red, value: 4.0)
        let item4 = KKChartDataItem.itemWith(identifier: "", color: UIColor.purple, value: 1.0)
        
        let screenWidth = UIScreen.main.bounds.width
        
        pieChartView = KKPieChartView.init(frame: CGRect.init(x: (screenWidth - 240)/2.0 , y: 100, width: 240, height: 240))
        pieChartView!.arr_chartItems = [item1,item2,item3,item4]
        self.view.addSubview(pieChartView!)
        pieChartView!.kk_updateChartViewUI()
        
        cyclicChartView = KKCyclicChartView.init(frame: CGRect.init(x: (screenWidth - 240)/2.0 , y: 360, width: 240, height: 240))
        cyclicChartView!.arr_chartItems = [item1,item2,item3,item4]
        self.view.addSubview(cyclicChartView!)
        cyclicChartView!.kk_updateChartViewUI()
    }
    
    @IBAction func action_reload(){
        
        pieChartView!.kk_updateChartViewUI()
        
        cyclicChartView!.kk_updateChartViewUI()
    }
}
